<!--conf
<sample in_favorites="true">
              <product version="1.4" edition="pro"/>
                     <modifications>
                            <modified date="070101"/>
                     </modifications>
               <sampledescription><![CDATA[You can export dhtmlxTreeGrid content into XML string any time calling just one method.  ]]></sampledescription></sample>
 --> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>TreeGrid serialization</title>
	
</head>

<body>
<link rel='STYLESHEET' type='text/css' href='../common/style.css'>
<table cellspacing="0" cellpadding="0" class="sample_header" border="0">
	<tr valign="middle">
		<!-- COMPONENT ICON -->
		<td width="40" align="center"><img src="../common/dhtmlxtreegrid_icon.gif" border="0"></td>
		<!-- COMPONENT NAME -->
		<td width="150" align="left" nowrap="true">Sample: dhtmlxTreeGrid</td>
		<!-- SAMPLE TITLE -->
		<td width="0" align="left" nowrap><b>TreeGrid serialization</b></td>
		<!-- LINK TO COMPONENT PAGE -->
		<td width="0" align="right"><a href="http://www.dhtmlx.com/docs/products/dhtmlxTreeGrid/index.shtml">dhtmlxTreeGrid main page</a></td>
		<!-- CLOSE BUTTON -->
		<td width="50"><div class="sample_close"><a href="javascript:void(0);" onclick="self.close();"><img src="../common/sample_close.gif" width="14" height="14" border="0" alt="X"></a></div></td>
	</tr>
</table>
	
	
	<p>
    Serialization for dhtmlxTreeGrid gives you actual state of the content in xml format. 
	<br>
		Math formulas can be serialized as formulas or as values.
	</p>
	<link rel="STYLESHEET" type="text/css" href="../../../dhtmlxGrid/codebase/dhtmlxgrid.css">
	<script  src="../../../dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
	<script  src="../../../dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
	<script  src="../../../dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
	<script  src="../../codebase/dhtmlxtreegrid.js"></script>
	<script  src="../../../dhtmlxGrid/codebase/ext/dhtmlxgrid_math.js"></script>
	<table width="835">
		<tr>
			<td width="600px">
				<div id="gridbox" width="100%" height="250px" style="background-color:white;"></div>
			</td>
            <td valign="top">
                <textarea style='width:300px; height:230px;'></textarea><div><a href="#" onclick="this.parentNode.previousSibling.value=mygrid.serialize()">Serialize TreeGrid</a></div>

            </td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
	</table>

<div class='sample_code'><div class="hl-main"><pre><span class="hl-code"> 
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">div</span><span class="hl-code"> </span><span class="hl-var">id</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">gridbox</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">width</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">100%</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">height</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">250px</span><span class="hl-quotes">&quot;</span><span class="hl-code"> </span><span class="hl-var">style</span><span class="hl-code">=</span><span class="hl-quotes">&quot;</span><span class="hl-string">background-color:white;overflow:hidden</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">&gt;</span><span class="hl-brackets">&lt;/</span><span class="hl-reserved">div</span><span class="hl-brackets">&gt;</span><span class="hl-code">
</span><span class="hl-brackets">&lt;</span><span class="hl-reserved">script</span><span class="hl-brackets">&gt;</span><span class="hl-code"><div class="hl-main"><pre><span class="hl-code"> 
    </span><span class="hl-identifier">mygrid</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">dhtmlXGridObject</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">gridbox</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
    ...
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">loadXML</span><span class="hl-brackets">(</span><span class="hl-quotes">&quot;</span><span class="hl-string">grid_math2.xml</span><span class="hl-quotes">&quot;</span><span class="hl-brackets">)</span><span class="hl-code">;
    ...
    </span><span class="hl-comment">//</span><span class="hl-comment">enabling math serialization</span><span class="hl-comment"></span><span class="hl-code">
    </span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">enableMathSerialization</span><span class="hl-brackets">(</span><span class="hl-reserved">true</span><span class="hl-brackets">)</span><span class="hl-code">;
    </span><span class="hl-comment">//</span><span class="hl-comment">serialize treegrid</span><span class="hl-comment"></span><span class="hl-code">
    </span><span class="hl-reserved">var</span><span class="hl-code"> </span><span class="hl-identifier">a</span><span class="hl-code">=</span><span class="hl-identifier">mygrid</span><span class="hl-code">.</span><span class="hl-identifier">serialize</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;</span></pre></div></span><span class="hl-brackets">&lt;/</span><span class="hl-reserved">script</span><span class="hl-brackets">&gt;</span></pre></div></div>

<script>
	mygrid = new dhtmlXGridObject('gridbox');
	mygrid.setImagePath("../../../dhtmlxGrid/codebase/imgs/icons_books/");
	mygrid.setHeader("Title,Price,Quantity,Total");
	mygrid.setInitWidths("250,100,80,100")
	mygrid.setColAlign("left,right,right,right")
	mygrid.setColTypes("tree,price,ed[=sum],price[=sum]");
	mygrid.setColSorting("str,int,int,int")
	mygrid.setColumnColor("#d5f1ff")
    mygrid.setMathRound(2);
	mygrid.init();
	mygrid.loadXML("treegrid_sample.xml");
</script>
<div><a href="#" onclick="mygrid.deleteSelectedItem()">Delete selected rows</a></div>
<div><a href="#" onclick="mygrid.addRowBefore((new Date()).valueOf(),['new row','text','text',1,0],mygrid.getSelectedId())">addRowBefore selected rows</a></div>
<div><a href="#" onclick="mygrid.addRowAfter((new Date()).valueOf(),['new row','text','text',1,0],mygrid.getSelectedId())">addRowAfter selected rows</a></div>


<!-- FOOTER -->
<table callspacing="0" cellpadding="0" border="0" class="sample_footer"><tr><td style="padding-left: 8px;">&copy; <a href="http://www.dhtmlx.com">DHTMLX LTD</a>. All rights reserved</td></tr></table>
<!-- FOOTER -->

</body>
</html>
